<?php
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 网城创想多用户商城 项目的一部分
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : member_personal_certify.manage.php   FILE_PATH : E:\www\\trunk\system\member_personal_certify.manage.php
 * ....会员个人实名认证
 *
 * @copyright workflow_system 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Thu Dec 11 11:02:52 CST 2008
 */

require ("../global.inc.php");

class SysPersonalCertify extends SystemFrameWork{
	/**
	 * 分页对象
	 *
	 * @var obj
	 */
	var $obj_page;
	/**
	 * 会员对象
	 *
	 * @var obj
	 */
	var $obj_member;
	/**
	 * 验证对象
	 *
	 * @var obj
	 */
	var $obj_validate;
	
	function main(){
		/**
		 * 初始化分页类
		 */
		if (!is_object($this->obj_page)){
			require_once("commonpage.class.php");
			$this->obj_page = new CommonPage();
		}
		/**
		 * 创建会员对象
		 */
		if (!is_object($this->obj_member)){
			require_once ("member.class.php");
			$this->obj_member = new MemberClass();
		}
		/**
		 * 创建验证对象
		 */
		if (!is_object($this->obj_validate)){
			require_once("commonvalidate.class.php");
			$this->obj_validate = new CommonValidate();
		}
		
		/**
		 * 语言包
		 */
		$this->getlang("sys_personal_certify.manage");
		
		switch($this->_input['action']){
			case "list":
				$this->_list();
				break;
			case "ajax_list":
				$this->_ajax_list();
				break;
			case "modi":
				$this->_modi();
				break;
			case "update":
				$this->_update();
				break;
			case 'batch_update':
				$this->_batch_update();
				break;
			default:
				$this->_list();
		}
	}
	
	/**
	 * 投票列表
	 */
	function _list(){
		$this->_ajax_list();
	}
	
	/**
	 * ajax 列表
	 */
	function _ajax_list(){
		//检索条件
		//申请状态
		if ($this->_input['certify_state'] != ''){
			$obj_condition['personal_certify'] = $this->_input['certify_state'];
		}else {
//			$this->_input['certify_state'] = 1;//用于前台搜索
//			$obj_condition['personal_certify'] = 1;//申请认证
		}
		//排除状态
		$obj_condition['no_personal_certify'] = '0';
		
		//会员名
		if ($this->_input['member_name'] != ''){
			$obj_condition['name'] = $this->_input['member_name'];
		}
		//会员列表
		$this->obj_page->pagebarnum(12);
		$this->obj_page->nowindex = $this->_input['curpage']?$this->_input['curpage']:1;
		$member_array = $this->obj_member->getMemberList($obj_condition,$this->obj_page,'*','more');
		$page_list = $this->obj_page->show(2);
		/**
		 * 页面输出
		 */
		$this->output('condition',$this->_input);
		$this->output('member_array',$member_array);
		$this->output("curpage", $this->obj_page->nowindex);
		$this->output('page_list',$page_list);
		$this->showpage('sys_member_personal_certify.list');
	}
	
	/**
	 * 查看
	 */
	function _modi(){
		$this->obj_validate->setValidate(array("input"=>$this->_input['id'],"require"=>"true","validator"=>"Number","message"=>$this->_lang['langSysCIDErr']));
		$error = $this->obj_validate->validate();
		if($error != ""){
			$this->redirectPath('error','',$error,1);
		}else{
			$condition['id'] = $this->_input['id'];
			$member_array = $this->obj_member->getMemberInfo($condition,'*','more');
			/**
			 * 页面操作
			 */
			$this->output('condition',$this->_input);
			$this->output('member_array',$member_array);
			$this->showpage("sys_member_personal_certify.modi");
		}
	}
	
	/**
	 * 保存修改信息
	 */
	function _update(){
		$this->obj_validate->setValidate(array("input"=>$this->_input['member_id'],"require"=>"true","validator"=>"Number","message"=>$this->_lang['langSysCIDErr']));
		$error = $this->obj_validate->validate();
		if($error != ""){
			$this->redirectPath('error','',$error,1);
		}else {
			if ($this->_input['sel_state'] == '3'){//判断是否是拒绝认证，如果是，则合并拒绝原因
				$condition['id'] = $this->_input['member_id'];
				$member_array = $this->obj_member->getMemberInfo($condition,'*','more');
				$member_array['personal_certify_deny_reason'] = addslashes("<div style='margin:10px 0; background: #feffe6; border: 1px solid #efefef;padding:5px 10px;color:#222;'><span style='color:blue'>". $this->_lang['langSysPersonalCertifySystemReason'] ."(".date('Y-m-d H:i:s').")：</span><br>".$member_array['personal_certify_deny_reason']."<br>".$this->_input['personal_certify_deny_reason']."</div>");
			}
			//更新会员资料
			$array = array();
			$array['personal_certify'] = $this->_input['sel_state'];
			$array['personal_certify_deny_reason'] = $member_array['personal_certify_deny_reason'];
			$result = $this->obj_member->modifyMember($array,$this->_input['member_id'],"personal_certify");
			if ($result === true){//成功
				//记录操作日志
				SystemPowerClass::addSysLog($this->_lang['langSysPersonalCertifyLogOperate']);
				$this->redirectPath('error','./member_personal_certify.manage.php?action=list',$this->_lang['errSysPersonalCertifyOperateIsSucc'],1);
			}else {
				$this->redirectPath('error','',$this->_lang['errSysPersonalCertifyOperateIsFail'],1);
			}
		}
	}
	
	/**
	 * 批量更新
	 */
	function _batch_update(){
		$this->obj_validate->setValidate(array("input"=>$this->_input['member_id'],"require"=>"true","message"=>$this->_lang['langSysPersonalCertifyBatchUpdateIsEmpty']));
		$error = $this->obj_validate->validate();
		if($error != ""){
			$this->redirectPath('error','',$error,1);
		}else {
			if (is_array($this->_input['member_id'])){
				foreach ($this->_input['member_id'] as $k => $v){
					$array = array();
					$array['personal_certify'] = $this->_input['state'];
					$result = $this->obj_member->modifyMember($array,$v,"personal_certify");
				}
				//记录操作日志
				SystemPowerClass::addSysLog($this->_lang['langSysPersonalCertifyLogOperate']);
				$this->redirectPath('error','',$this->_lang['errSysPersonalCertifyOperateIsSucc'],1);
			}else {
				$this->redirectPath('error','',$this->_lang['errSysPersonalCertifyOperateIsFail'],1);
			}
		}
	}
}
$personal_certify_manage = new SysPersonalCertify();
$personal_certify_manage->main();
unset($personal_certify_manage);
?>